$.ajax({
    url: '/admin//categories',
    success: function (reslut) {
        var html = template('data', {data: reslut});
		$('#tbody').html(html);
    }
})
$('#tbody').on('click', '.delete', function() {
    if (confirm('您真的要进行删除操作吗')) { 
        var id = $(this).attr('data-id');
        $.ajax({
            type: 'post',
            url: '/admin/categoriesDel',
            data: {
                id
            },
            success: function (reslut) {
            window.location.href = "categories.html"
                
            }
       })
    }
})

$('.add').on('submit', function () {
    var formData = $(this).serialize();
    $.ajax({
        type: 'post',
        url: '/admin/categoriesAdd',
        data:formData,
        success: function (reslut) {
            window.location.href = "categories.html"
        }
    })
    // 阻止表单提交
    return false
})